import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { BaseItem } from "../../common/BaseItem";
import { Language } from "../../../../../extend/language/Language";
import { GNumericStepper } from "../../../../../com/mui/controls/GNumericStepper";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DataEvent } from "../../../events/DataEvent";
import { JewelExchangeOperateItem } from "./JewelExchangeOperateItem";
import { ItemData } from "../../../resource/info/ItemData";
import { SmeltConfig } from "../../../resource/SmeltConfig";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
type int = number;
//class SpecialJewelOperRenderer
    
    export  class SpecialJewelOperRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.createChildren();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._nameLabel = ObjCreate.createLabel("", 0, 0, 190, 20, flash.text.TextFormatAlign.CENTER, this, true);
            this._nameLabel.drawNow();
            this._item = new BaseItem();
            this._item.setSize(60, 60);
            this._item.isShowLock = true;
            this._item.move(3, 24);
            this._item.setAmountLabelPos(0, 45);
            this._item.addEventListener(flash.events.MouseEvent.CLICK, this.onItemClick);
            this.addChild(this._item);
            ObjCreate.createLabel(Language.getString(69230), 70, 28, 50, 20, flash.text.TextFormatAlign.LEFT, this, true, 16776960).drawNow();
            ObjCreate.createLabel(Language.getString(69231), 70, 55, 50, 20, flash.text.TextFormatAlign.LEFT, this, true, 16776960).drawNow();
            this._numStepper = new GNumericStepper();
            this._numStepper.setSize(49, 22);
            this._numStepper.move(110, 27);
            this._numStepper.styleName = "NumericStepper";
            this._numStepper.addEventListener(flash.events.Event.CHANGE, this.onTransNumberChange);
            this._numStepper.drawNow();
            this._numStepper.textField.setStyle("upSkin", GlobalClass.getScaleBitmap("WindowCenterB", new Object /* flash.geom.Rectangle */(4, 4, 36, 21)));
            this._numStepper.textField.drawNow();
            this._numStepper.maximum = 99;
            this._numStepper.minimum = 1;
            this.addChild(this._numStepper);
            this._costLabel = ObjCreate.createLabel("", 106, 56, 70, 20, flash.text.TextFormatAlign.LEFT, this, true, GlobalStyle.color1Uint);
            this._costLabel.drawNow();
            this._ybBm = ObjCreate.createBitmap(ImagesConst.Yuanbao, 135, 56, this);
            return;
        }

        /* internal  */onItemClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.dispatchEvent(new DataEvent(JewelExchangeOperateItem.MoveOutJewel, data["itemData"], false, true, true));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            if (arg1) 
            {
                loc1 = data["itemData"] as ItemData;
                this._price = SmeltConfig.instance.getJewelTransCostByCode(loc1.type, loc1.itemInfo.item.itemLevel);
                this._item.itemData = loc1;
                this._nameLabel.htmlText = ItemsUtil.getItemName(loc1);
                data["transNum"] = arg1["transNum"];
                data["cost"] = this._price * arg1["transNum"];
                this._numStepper.maximum = loc1.itemAmount;
                this._numStepper.value = data["transNum"];
                this.onTransNumberChange();
            }
            return;
        }

        /* internal  */onTransNumberChange(arg1: Object /* flash.events.Event */=null): void
        {
            data["transNum"] = this._numStepper.value;
            data["cost"] = this._price * this._numStepper.value;
            this._item.setAmountText(this._numStepper.value);
            this._costLabel.htmlText = String(data["cost"]);
            this._ybBm.x = this._costLabel.x + this._costLabel.textField.textWidth + 5;
            Dispatcher.dispatchEvent(new DataEvent(EventName.SmeltJewelTransCountCost));
            return;
        }

        /* internal */ /* var */_nameLabel: GLabel;

        /* internal */ /* var */_item: BaseItem;

        /* internal */ /* var */_numStepper: GNumericStepper;

        /* internal */ /* var */_costLabel: GLabel;

        /* internal */ /* var */_ybBm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_price: int;
    }
